package fr.cpe.j2ee.projet.war;

import java.util.List;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;

import fr.cpe.j2ee.projet.ejb.ConversationSession;
import fr.cpe.j2ee.projet.model.Conversation;

public class ChatRoomBean {
	private List<Conversation> conversations;

	@EJB
	private ConversationSession conversationSession;
	
	// Managed Property
	private LoginBean loginBean;
	
	public ChatRoomBean() {
		
	}
	
	@PostConstruct
	public void init() {
		if(loginBean != null) {
			if(loginBean.isLogged()) {
				conversations = conversationSession.findByEmployeeId(loginBean.getEmployee().getEmpId());
			}
		} else {
			System.out.println("Le loginBean vaut Null - Impossible de rapatrier la liste des conversations");
		}
	}
	
	public List<Conversation> getConversations() {
		return conversations;
	}
	
	public void setLoginBean(LoginBean loginBean) {
		this.loginBean = loginBean;
	}
}
